﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CH.TestData.Common;
using System.Windows.Forms;

namespace CH.TestData.Provider
{
    [DataTypeName("固定字符串")]
    public class FiexdStringProvider : IDataProvider
    {

        private string columnName;
        private int length;
        public void SetDataSource(FlowLayoutPanel flp)
        {
            TextBox txtColumnName = flp.Controls.Find("txtColumnName", false).First() as TextBox;
            this.columnName = txtColumnName.Text;

            TextBox txtFixed = flp.Controls.Find("txtFixed", true).First() as TextBox;
            this.length = int.Parse(txtFixed.Text);
        }
        public void CreateOption(FlowLayoutPanel flp)
        {
            Label lblc = new Label();
            lblc.Text = "生成固定";
            lblc.Width = 30;
            lblc.Margin = new Padding(0, 7, 0, 0);
            flp.Controls.Add(lblc);

            TextBox txtFrom = new TextBox();
            txtFrom.Name = "txtFixed";
            txtFrom.Text = "10";
            txtFrom.Width = 60;
            txtFrom.Margin = new Padding(0, 3, 0, 0);
            flp.Controls.Add(txtFrom);

            Label lblzf = new Label();
            lblzf.Text = "个字符";
            lblzf.Width = 50;
            lblzf.Margin = new Padding(0, 7, 0, 0);
            flp.Controls.Add(lblzf);
        }

        public string GetNextValue()
        {
            return "N'" + RandomHelper.GetRandomString(this.length) + "'";
        }
    }
}
